package com.ysd.modules.app.controller;

import com.ysd.common.utils.R;
import com.ysd.modules.app.entity.NoteReply;
import com.ysd.modules.app.entity.OptionsRecordsEntity;
import com.ysd.modules.app.entity.StudentNote;
import com.ysd.modules.app.entity.TopicEntity;
import com.ysd.modules.app.service.StudentNoteService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author ky
 * @Date 2021/07/31
 * 学生笔记相关
 */
@RestController
@RequestMapping("/app")
@Api(description = "APP学生笔记相关接口")
public class AppStudentNoteController {
    @Autowired
    private StudentNoteService studentNoteService;

    @PostMapping("studentNote/insert")
    @ApiOperation("章节练习-学员笔记-发布笔记")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stuId", value = "学生ID", paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "topicId", value = "题目ID", paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "content", value = "回复内容", paramType = "query", dataType = "string"),
    })
    public R insert(Integer stuId, Integer topicId, String content) {
        int len = studentNoteService.insert(stuId, topicId, content);
        return R.ok().put("result", len);
    }

    @PostMapping("addReply")
    @ApiOperation("章节练习-学员笔记-回复")
    public R addReply(@RequestBody NoteReply noteReply) {
        int len = studentNoteService.addReply(noteReply);
        return R.ok().put("result", len);
    }

    @PostMapping("studentNoteList")
    @ApiOperation("章节练习-学员笔记-列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "topicId", value = "题目ID", paramType = "query", dataType = "int"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK", response = StudentNote.class)
    })
    public R studentNoteList(Integer topicId) {
        List<StudentNote> studentNoteList = studentNoteService.studentNoteList(topicId);
        return R.ok().put("studentNoteList", studentNoteList);
    }

    @PostMapping("myStudentNoteList")
    @ApiOperation("学员-我的笔记列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stuId", value = "学生ID", paramType = "query", dataType = "int"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK", response = StudentNote.class)
    })
    public R myStudentNoteList(Integer stuId) {
        List<StudentNote> studentNoteList = studentNoteService.myStudentNoteList(stuId);
        return R.ok().put("studentNoteList", studentNoteList);
    }

    @PostMapping("studentNote/delete")
    @ApiOperation("笔记-删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "笔记ID", paramType = "query", dataType = "int"),
    })
    public R delete(Integer id) {
        int len = studentNoteService.delete(id);
        return R.ok().put("result", len);
    }
}
